package com.webservice.client;

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.nio.charset.Charset;

public class Test {
	public Test(){
		
	}

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		IPubWebService service=new PubWebServiceImplService().getPubWebServiceImplPort();
		System.out.println(service.upLoad(new Test().getXml("B1001","xml"), "B1001"));
	}
	
	


	 //读取固定的XML文件
	public  String getXml(String str,String type){
		String filename =null;
		File file = null;
		InputStreamReader input =null;
		StringBuffer sb =null;
		filename = str+"."+type;
		String path=this.getClass().getResource("../test/").getPath();
		System.out.println("-----文件的名称："+filename);
		sb =new StringBuffer();
		try {
			//"D://workspace/PubWebService/src/com/webservice/test/"
			file = new File(path+filename);
			input= new InputStreamReader(new FileInputStream(file), Charset.forName("UTF-8"));
			int length = -1 ;
			char[] arry =new char[1024];
		  
			while((length=input.read(arry))!= -1){
				sb.append(arry, 0, length);
			}
			input.close();
		    //System.out.println("------xml的内容:"+sb.toString());
			
		} catch (IOException e) {
			e.printStackTrace();
		}
		return sb.toString();
	}

}
